var subsets = function (nums) {
  let n = nums.length;
  let res = [];
  function dfs(path, start) {
    res.push(path);
    for (let i = start; i < n; i++) {
      path.push(nums[i]);
      dfs(path.slice(), i + 1);
      path.pop();
    }
  }
  dfs([], 0);
  return res;
};
